/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.sll.engagemangsindex.ejb;

import java.io.IOException;
import java.util.Properties;
import javax.ejb.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Singleton class for holding runtime configuration read from a properties file.
 * @author khaleddaham
 */
@Singleton
public class ConfigurationHolder {
    
    private static final Logger LOG = (Logger) LoggerFactory.getLogger(ConfigurationHolder.class);
    private Properties properties = null;

    /**
     * By default we look for engagemangsindex.properties in our classpath.
     */
    public ConfigurationHolder() {
        try {
            properties = new Properties();
            this.properties.load(Thread.currentThread().getContextClassLoader().getResource("engagemangsindex.properties").openStream());
        } catch (IOException ex) {
            LOG.error("Unable to initialize configuration.", ex);
        }
    }

    /**
     * Used for testing.
     * @param properties 
     */
    ConfigurationHolder(Properties properties) {
        this.properties = properties;
    }

    /**
     * 
     * @return 
     */
    public String getServiceCatalogue() {
        return this.properties.getProperty("service.catalogue");
    }

    /**
     * 
     * @return 
     */
    public String getOwner() {
        return this.properties.getProperty("engagemangsindex.owner");
    }
}